<?php include(TPL_PATH . '/admin/inc_header.php'); ?>
<?php include(TPL_PATH . '/admin/inc_top.php'); ?>

<link rel="stylesheet" href="<?php p(HTTP_URL) ?>/statics/kindeditor/themes/default/default.css" />
<!--<link rel="stylesheet" href="<?php p(HTTP_URL) ?>/statics/kindeditor/plugins/code/prettify.css" />-->
<script type="text/javascript" src="<?php p(HTTP_URL) ?>/statics/kindeditor/kindeditor.js"></script>
<script type="text/javascript">

$(document).ready(function() {
	$('input[type=text]').tooltip({'placement':'right'});
	var editor;
    KindEditor.ready(function(K) {
    	editor = K.create('textarea[name="txt"]', {
            autoHeightMode:true,
            afterCreate:function() {
            	this.loadPlugin('autoheight', function() {
            		// this.loadPlugin('code');
                });
            },
            items:['source', 'preview', 'selectall', '|', 'undo', 'redo', '|', 'cut', 'copy', 'paste',
                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                'justifyfull', '|', 'insertorderedlist', 'insertunorderedlist', '|', 'indent', 'outdent', 'lineheight', '|',
                'subscript', 'superscript', '|', 'formatblock', 'fontname', 'fontsize', 'forecolor', 'hilitecolor',
                '/', 'bold', 'italic', 'underline', 'strikethrough', 'removeformat', '|', 'emoticons', 'image', 'multiimage', 'flash',
                'media', 'insertfile', 'code', 'map', 'baidumap', '|', 'table', 'hr', '|', 'link', 'unlink', 'anchor', '|',
                'clearhtml', 'quickformat', '|', 'fullscreen', 'print', '|', 'about'
            ],
            uploadJson:'<?php p(HTTP_URL) ?>/index.php?m=admin&c=file&a=upload_all',
            filePostName:'img_file',
            newlineTag:'br'
        });
    });
});
function do_clean(id) {
	if (confirm('删除后不可还原,确定删除吗?')) {
		window.location.href = '<?php p(HTTP_URL) ?>/index.php?m=admin&c=content&a=clean_page&id=' + id;
	}
}
</script>

<form action="<?php p(HTTP_URL); ?>/index.php?m=admin&c=content&a=<?php if ($blnAdd) { ?>add_page<?php } else { ?>edit_page&page_id=<?php p($page_id); } ?>&content_id=<?php p($content_id) ?>" method="post">
    <fieldset>
    	<legend><?php (!$blnAdd) ? p('编辑内容页') : p('添加新内容页') ?> - <?php p($arrContentData['title']) ?></legend>
    	
    	<?php if (!empty($strMsg)) { ?>
		<div class="alert alert-error">
			<button type="button" class="close" data-dismiss="alert">&times;</button>
			<?php p($strMsg) ?>
		</div>
		<?php } elseif (!empty($strOk)) { ?>
    	<div class="alert alert-success">
			<button type="button" class="close" data-dismiss="alert">&times;</button>
			<?php p($strOk) ?>
		</div>
    	<?php } ?>
    	
        <label for="id_title">标题</label>
    	<input type="text" class="input-xxlarge" name="title" id="id_title" value="<?php p($arrData['title']) ?>" title="非必填项,80字以内" />
    	
    	<label for="id_txt">内容</label>
    	<textarea id="id_txt" name="txt" style="width:100%; height:500px;"><?php p($arrData['txt']) ?></textarea>
        
    	<?php if (!$blnAdd) { ?>
    	<br />
        <label class="checkbox">
            <input name="rec_status" type="checkbox" <?php if ($arrData['rec_status']) { ?>checked="checked"<?php } ?> value="1" /> 可用状态
        </label>
        <?php } ?>
        <br />
        <input type="submit" class="btn btn-primary" name="sub_btn" value="<?php if (!$blnAdd) { ?>保存修改<?php } else { ?>添加<?php } ?>" />
        <?php if (!$blnAdd) { ?>
        <a class="btn btn-danger" href="javascript:do_clean(<?php p($page_id) ?>);">删除</a>
        <?php } ?>
        <input class="btn" type="button" onclick="window.opener = null; window.open('', '_self'); window.close();" value="取消" />
    </fieldset>
</form>

<?php include(TPL_PATH . '/admin/inc_bottom.php'); ?>
<?php include(TPL_PATH . '/admin/inc_footer.php'); ?>